﻿package com.scn.base.web;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.scn.base.domain.MenuVO;
import com.scn.base.page.TreeNode;
import com.scn.base.service.ISysMenuService;
import com.scn.base.util.DESUtil;

@Controller
public class SysMenuController {
	@Autowired
	private ISysMenuService sysMenuService;
	
	@RequestMapping(value="/menuList.html")
	public ModelAndView menuList(){
		ModelAndView mav=new ModelAndView("/sysrole/roleFuncList");
		mav.addObject("userMenu", sysMenuService.selectMenu());
		return mav;
	}
	/**
	 * 功能描述：菜单清单
	 * @return 视图模型
	 */
	@RequestMapping(value="/menuListAll.html")
	public ModelAndView menuListAll(){
		ModelAndView mav=new ModelAndView("/sysmenu/menuList");
		TreeNode root=sysMenuService.selectMenuList();
		mav.addObject("roottree", root);
		return mav;
	}
	/**
	 * 功能描述：添加菜单页面
	 * @return 视图模型
	 */
	@RequestMapping(value="/addMenuView.html")
	public ModelAndView addMenuView(){
		ModelAndView mav=new ModelAndView("/sysmenu/addMenu");
		return mav;
	}
	/**
	 * 功能描述：添加菜单
	 * @param smpid  菜单父节点
	 * @param smimg		菜单图片
	 * @param smimg		菜单名称
	 * @param smview	是否显示
	 * @param smurl		菜单地址
	 * @param smpomp	是否弹出
	 * @return 视图模型
	 */
	@RequestMapping(value="/addMenu.html")
	public ModelAndView addMenu(String smpid,String smname,String smimg,String smview,String smurl,String smpomp){
		MenuVO menu=new MenuVO();
		menu.setPid(smpid);
		menu.setName(smname);
		menu.setUrl(smurl);
		menu.setView(1);
		menu.setImg(smimg);
		sysMenuService.saveMenu(menu);
		return new ModelAndView("redirect:/addMenuView.html?SCNMessage="+DESUtil.encrypt("菜单【"+smname+"】添加成功！"));
	}
}
